package org.dbstar.scheduler.control.db.operate;

import org.dbstar.scheduler.beans.OperateType;
import org.dbstar.scheduler.control.OperateController;
import org.dbstar.scheduler.control.db.JdbcTemplateDao;
import org.dbstar.scheduler.control.exception.DaoException;
import org.springframework.jdbc.core.JdbcTemplate;


/**
 * 使用JdbcTemplate的OperateController实现类。
 * 
 * @author 代波
 * @since 1.0.0
 * @version 1.0.0
 * @date 2012-6-5
 */
public class JdbcTemplateOperateController extends JdbcTemplateDao implements OperateController {
	private final OperateInsert insert;

	public JdbcTemplateOperateController(JdbcTemplate jt) {
		super(jt);
		this.insert = new OperateInsert(jt);
	}

	@Override
	public int operate(String operator, OperateType operate, String parameter) throws DaoException {
		try {
			return insert.insertOperate(operator, operate, parameter);
		} catch (Throwable e) {
			throw new DaoException(e);
		}
	}
}
